//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
const stu_num = 3;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
struct stuType
{
    char *name;
    float score;
};
stuType student[stu_num];

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{

}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
    student[0].name = "޼";
    student[0].score = 98.8;
    student[1].name = "Ŵɽ";
    student[1].score = 90.0;
    student[2].name = "";
    student[2].score = 79.8;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    float score;
    int grade,i;
    for(i=0;i<stu_num;i++)
    {
        if(Edit1->Text==student[i].name)
        {
           score = student[i].score;
           break; //˳forѭ
        } 
    }
    if(i==stu_num) {Label3->Caption = "ûѧ"; return;}
    grade = score/10;
    switch(grade)
    {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5: Label3->Caption = ""; break;
        case 6: Label3->Caption = "";   break;
        case 7: Label3->Caption = "еȣ";   break;
        case 8: Label3->Caption = "ã";   break;
        case 9: Label3->Caption = "㣡";   break;
        case 10: Label3->Caption = "㣡";  break;
        default:  Label3->Caption = "ɼ";   
    } 
}
//---------------------------------------------------------------------------
